
import { ModalForm, ProFormDigit, ProFormRadio, ProFormDependency, ProFormText } from '@ant-design/pro-components';
import { Form } from 'antd';

export default function CraftGroupDialog({children, onFinish, onlyMissionsOrder, auto_mission_order}) {
  const [form] = Form.useForm();
  return (
    <ModalForm
      title={onlyMissionsOrder ? "盟约收菜" : "制造集合"}
      trigger={children}
      form={form}
      autoFocusFirstInput
      modalProps={{
        destroyOnClose: true,
      }}
      submitTimeout={2000}
      onFinish={values => {
        onFinish(values)
        return true
      }}
    >
      <ProFormDigit
        name="start_idx"
        label="start_idx"
        initialValue={0}
      />

      <ProFormDigit
        name="limit"
        label="limit"
        initialValue={0}
      />
      <ProFormRadio.Group
        name="reset_keyboard"
        label="重置按键"
        initialValue={0}
        options={[
          {label: '是', value: 1},
          {label: '否', value: 0},
        ]}
      />
      <ProFormRadio.Group
        name="get_emails"
        label="收邮件"
        hidden={Boolean(onlyMissionsOrder)}
        initialValue={0}
        options={[
          {label: '是', value: 1},
          {label: '否', value: 0},
        ]}
      />
      <ProFormRadio.Group
        name="create_dn_object"
        label="制造点火"
        hidden={Boolean(onlyMissionsOrder)}
        initialValue={0}
        options={[
          {label: '是', value: 1},
          {label: '否', value: 0},
        ]}
      />
      <ProFormRadio.Group
        name="profession_type"
        label="专业"
        hidden={Boolean(onlyMissionsOrder)}
        initialValue={0}
        options={[
          {label: '全部', value: 0},
          {label: '仅锻造', value: 1},
          {label: '仅附魔', value: 2},
        ]}
      />
      <ProFormRadio.Group
        name="auto_mission_order"
        label="盟约收菜"
        hidden={Boolean(onlyMissionsOrder)}
        initialValue={auto_mission_order ? 1 : 0}
        options={[
          {label: '是', value: 1},
          {label: '否', value: 0},
        ]}
      />
      <ProFormRadio.Group
        name="auto_run_record_events"
        label="按键播放"
        initialValue={0}
        options={[
          {label: '是', value: 1},
          {label: '否', value: 0},
        ]}
      />
      <ProFormDependency name={['auto_run_record_events']}>
        {({ auto_run_record_events }) => {
          return auto_run_record_events ? (
            <ProFormText label="录制文件" name="record_events_file" initialValue={"f1_abs_1753415202.json"} placeholder={"录制文件"} />
          ) : null;
        }}
      </ProFormDependency>
      <ProFormRadio.Group
        name="auto_craft"
        label="制造收菜"
        hidden={Boolean(onlyMissionsOrder)}
        initialValue={Boolean(onlyMissionsOrder) ? 0 : 1}
        options={[
          {label: '是', value: 1},
          {label: '否', value: 0},
        ]}
      />
      <ProFormRadio.Group
        name="auto_order"
        label="订单收菜"
        hidden={Boolean(onlyMissionsOrder)}
        initialValue={0}
        options={[
          {label: '是', value: 1},
          {label: '否', value: 0},
        ]}
      />
      <ProFormRadio.Group
        name="salvage_card"
        label="同时拆卡片"
        hidden={Boolean(onlyMissionsOrder)}
        initialValue={0}
        options={[
          {label: '是', value: 1},
          {label: '否', value: 0},
        ]}
      />
    </ModalForm>
  )
}